local dir `c(pwd)'
clear
set obs 4
generate id=_n
generate str description=""
foreach book in Acts John Luke Mark Matthew Revelation {
generate `book'_spearman=.
generate `book'_R=.
generate `book'_N=.
}
qui {
local i=1
replace description="Constant string size across languages" in `i'
foreach book in Acts John Luke Mark Matthew Revelation {
	noisily di "`book' VII"
	if "`book'"=="Acts" {
		local book_number=44
	}
	if "`book'"=="John" {
		local book_number=43
	}
	if "`book'"=="Luke" {
		local book_number=42
	}
	if "`book'"=="Mark" {
		local book_number=41
	}
	if "`book'"=="Matthew" {
		local book_number=40
	}
	if "`book'"=="Revelation" {
		local book_number=66
	}
	preserve
	use if book==`book_number' using entropy_bible_validation_VII, clear  
	merge m:1 trans using data_bible_final, keep(3) 
	collapse (mean) D*, by(language ISO) fast
	spearman D_order D_structure
	local rho: di %3.2f r(rho)
	gen reciprocal=1/D_order
	corr D_structure rec
	local corr: di %3.2f (r(rho))^2
	local N=r(N)
	restore
	replace `book'_spearman=`rho' in `i'
	replace `book'_R=(`corr') in `i'
	replace `book'_N=`N' in `i'
	}

local i=2
*Convergence Tests
qui {
foreach letter in IV III V {
if "`letter'"=="IV" {
	local condition=.10
	replace description="Convergence test: Entropies computed for first 50% of the string. Test criterion: maximum discrepancy of 10%" in `i'
	}
if "`letter'"=="III" {
	local condition=.05
	replace description="Convergence test: Entropies computed for first 75% of the string. Test criterion: maximum discrepancy of 5%" in `i'
	}
if "`letter'"=="V" {
	local condition=.025
	replace description="Convergence test: Entropies computed for first 87.5% of the string. Test criterion: maximum discrepancy of 2.5%" in `i'
	}		
foreach book in Acts John Luke Mark Matthew Revelation {
	noisily di "`book' `letter'"
	if "`book'"=="Acts" {
		local book_number=44
	}
	if "`book'"=="John" {
		local book_number=43
	}
	if "`book'"=="Luke" {
		local book_number=42
	}
	if "`book'"=="Mark" {
		local book_number=41
	}
	if "`book'"=="Matthew" {
		local book_number=40
	}
	if "`book'"=="Revelation" {
		local book_number=66
	}
	preserve
	use using entropy_bible_validation_`letter', clear  
	merge m:1 trans using data_bible_final, keep(3)
	merge 1:1 trans book using entropy_bible, gen(_con) keep(3)
	keep if book==`book_number' 
	gen convergence=0 
	foreach type in original order structure {
	gen convergence_`type'=H_`type'/H_`type'_convergence
	sum convergence_`type'	
	replace convergence=1 if convergence_`type'>(1+`condition')|convergence_`type'<(1-`condition')
	}
	sum convergence if convergence==1
	local dropped=r(N)
	drop if convergence==1
	*collapse (mean) D*, by(language ISO) fast
	spearman D_order D_structure
	local rho: di %3.2f r(rho)
	gen reciprocal=1/D_order
	corr D_structure rec
	local corr: di %3.2f (r(rho))^2
	local N=r(N)
	restore
	replace `book'_spearman=`rho' in `i'
	replace `book'_R=(`corr') in `i'
	replace `book'_N=`N' in `i'
	}
capture `++i'
}
}
}
replace description=string(id)+" "+description
drop id
export excel using "Table_1", firstrow(varlabels) replace
exit